package cn.etynit.mms.fallback;

import cn.etynit.domain.Expense;
import cn.etynit.exception.GlobalExceptionCodeEnum;
import cn.etynit.mms.feign.ExpenseService;
import cn.etynit.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ExpenseServiceFallbackFactory implements FallbackFactory<ExpenseService> {
    @Override
    public ExpenseService create(Throwable throwable) {
        return new ExpenseService() {
            @Override
            public JsonResult saveOrUpdate(Expense expense) {
                return JsonResult.error(GlobalExceptionCodeEnum.ERROR);
            }

            @Override
            public JsonResult inquireCost(Integer type, Long userId,Integer month) {
                return JsonResult.error(GlobalExceptionCodeEnum.ERROR);
            }

            @Override
            public JsonResult adviceCharge() {
                return JsonResult.success("费用通知出现故障，我们正在努力修复！");
            }
        };
    }
}
